﻿using System;
using BO.Infrastructure.StaticData;
using BO.Infrastructure.Utils;
using BO.News;
using ChannelVN.Cached.Base;
using ChannelVN.Cached.UrlRewrite;
using GUI.Extensions;
using ChannelVN.Cached;

namespace GUI
{
    public partial class Default : PageBase
    {
        #region Overrides of PageBase
        protected override string CacheConfigName
        {
            get { return "Default"; }
        }

        protected override bool IsCachedChanged(long newsId, string zoneId, long tagId)
        {
            return newsId > 0 || !string.IsNullOrEmpty(zoneId) || (newsId <= 0 && string.IsNullOrEmpty(zoneId));
        }
        #endregion

        private const int PageSize = 8;
        private const int NumberOfPageLoadFromNewsPosition = 3;
        private const int TopHighlight = 9;
        public string CssClass { get; set; }


        public int ZoneId = 10002;
        protected void Page_Load(object sender, EventArgs e)
        {

            var objCat = NewsBO.GetInstance().GetCategoryDetail(ZoneId);
            if (objCat != null)
            {
                ZoneId = objCat.Id;

                #region Title/MetaData
                var mtaCategory = NewsBO.GetInstance().GetCategoryMetaData(objCat.Id);

                if (mtaCategory != null)
                {
                    PresentationUtils.AddMeta(Page, DefinedConstants.MetaAttributes.Description.Id,
                                              DefinedConstants.MetaAttributes.Description.Name, mtaCategory.Description);
                    PresentationUtils.AddMeta(Page, DefinedConstants.MetaAttributes.Keywords.Id,
                                              DefinedConstants.MetaAttributes.Keywords.Name, mtaCategory.Keywords);
                    PresentationUtils.AddMeta(Page, DefinedConstants.MetaAttributes.NewsKeywords.Id,
                                              DefinedConstants.MetaAttributes.NewsKeywords.Name, mtaCategory.Keywords);
                    Page.Header.Title = string.Format(
                    "{0} | soha.vn",
                    mtaCategory.Title);
                }


                #endregion

                return;
            }

            _301Redirection.RedirectToFileNotFoundPage();
        }

    }
}
